<?php
include_once("../modules/checkA.php");
include_once("../../config.php");
$plate=select_one_line_all_items($table_Prefix."plate","mid = 'repair'");
?>


<?
//用来判断当前系统属于什么板块
$system_part = $plate['mid'];
include_once("detail-list-function.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!--網站語言--><meta http-equiv="Content-Language" content="zh-cn">
	<!--網站編碼--><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php include '../coresection/title.php'; ?></title>
	<link rel="Shortcut Icon" href="../coresection/logoicon.ico">


</head>

<body style="display:none">


<?php
$new_detail_nid=$_REQUEST['nid'];

$repairrecord=select_one_line_all_items($table_Prefix."repair","nid = '".$new_detail_nid."'");

$equipmentid=$repairrecord['equipmentid'];
$equipment_repairdate=$repairrecord['repairdate'];



//设置需要搜索的表格的前缀后缀
$table_Suffix=$plate['table_Suffix'];
$table=$table_Prefix.$table_Suffix;
//设置需要搜索的表格的前缀后缀

?>



<?php

$sql = " DELETE FROM $table WHERE nid=$new_detail_nid";
$query=mysql_query($sql) or die ('删除数据失败');
mysql_close($con);






//还要看看有没有比这条数据新的产品的数据，如果有的话，就不改变状态。

$new_result=count_by_item($table_Prefix."repair","equipmentid='".$equipmentid."' and repairdate > '".$equipment_repairdate."'");



if(!$new_result) {

	$table_Suffix = "equipment";
	$table        = $table_Prefix . $table_Suffix;
//设置需要搜索的表格的前缀后缀

	$sql = "update $table SET
status= '正常'
where nid='$equipmentid'";

$query = mysql_query($sql) or die ('更新数据失败');


}



?>










<script type="text/javascript">
	document.location.href = "detail-list.php?nav-itemed=equipment";
</script>

</body>